package com.itsu.mysql.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itsu.interfaces.entity.UserFreeze;
import com.itsu.interfaces.service.UserFreezeService;
import com.itsu.mysql.mappers.UserFreezeMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserFreezeServiceImpl implements UserFreezeService {

    @Autowired
    UserFreezeMapper userFreezeMapper;

    @Override
    public UserFreeze findByUid(Long id) {
        return userFreezeMapper.selectOne(Wrappers.lambdaQuery(UserFreeze.class)
                .eq(UserFreeze::getUserId, id));
    }

    @Override
    public int addUserFreeze(UserFreeze userFreeze) {
        return userFreezeMapper.insert(userFreeze);
    }

    @Override
    public int deleteUserFreezeByUid(Long uid) {
        return userFreezeMapper.delete(Wrappers.lambdaQuery(UserFreeze.class).eq(UserFreeze::getUserId, uid));
    }
}
